package controller

import (
	"net/http"
	"smart-flow/server/monitor"
	"smart-flow/server/proto"
	"strings"

	"github.com/gin-gonic/gin"
)

func Exchange(c *gin.Context) {
	var req proto.ExchangeReq
	if c.ShouldBindJSON(&req) != nil {
		c.JSON(http.StatusBadRequest, proto.NewCommonResp(proto.ParameterError))
		return
	}
	if strings.TrimSpace(req.MonitorIp) == "" || strings.TrimSpace(req.MachineId) == "" || strings.TrimSpace(req.Isp) == "" {
		c.JSON(http.StatusBadRequest, proto.NewCommonResp(proto.ParameterError))
		return
	}
	monitor.SaveContainer(&req)
	c.JSON(http.StatusOK, proto.NewCommonResp(proto.Success))
}
